package com.gitee.limaozhi.socket.lesson03.example3;

/**
 * IO处理空实现
 *
 * @author hzlimaozhi
 * @date 2019/08/07 15:16
 */
public class HandlerAdapter implements Handler {

    /** 上下文 */
    private HandlerContext context;

    /** 下个处理器 */
    private Handler next;

    @Override
    public Handler context(HandlerContext context) {
        this.context = context;
        return this;
    }

    @Override
    public HandlerContext context() {
        return context;
    }

    @Override
    public Handler next(Handler handler) {
        this.next = handler;
        return this;
    }

    @Override
    public Handler next() {
        return next;
    }

    @Override
    public Handler start() {
        if (next != null) {
            next.start();
        }
        return this;
    }

    @Override
    public Handler handle(Object object) {
        if (next != null) {
            next.handle(object);
        }
        return this;
    }

    @Override
    public Handler finish(int prevReq) {
        if (next != null) {
            next.finish(prevReq);
        }
        return this;
    }

}
